package cn.train.controler;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.train.service.VipCoderAndPassServices;

@WebServlet("/VipChangeStateServlet")
public class VipChangeStateServlet extends HttpServlet {

	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		String id=req.getParameter("id");
		String flag=req.getParameter("flag");
		int state=0;
		if(flag.equals("out")){
			 state=2;
		}else{
			state=3;
		}
		int oid=Integer.parseInt(id);
		VipCoderAndPassServices vaps=new VipCoderAndPassServices();
		int m=vaps.updatestate(state, oid);
		PrintWriter out=resp.getWriter();
		if(m>0){
			out.print(1);
		}else{
			out.print(0);
		}
	}
	
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doGet(req, resp);
	}
}
